home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 August
/
Macworld (1997-08).dmg
/
Shareware World
/
Info
/
For Developers
/
InstallerMaker™ 4.0 Installer
/
Customizing InstallerMaker
/
Sample Code
/
Utilities
/
PackStrParser.c
< prev
next >
Wrap
Text File
|
1995-08-03
|
6KB
|
169 lines
/******************************************************************************
**
** Project Name: InstallerMaker 3.0 Demo Code
** File Name: PackStrParser.c
**
** Description: This routine can parse a comma delimited string listing
** InstallerMaker 3.0 package bits.
**
** Packages field
** ==============
**
** The interpretation of packages for the code rsrcs is:
**
** IM 2.0: packages should be interpreted as a 16 bit field.
** Bit 0 is the lowest bit.
**
** IM 3.0: packages should be interpreted as a 128 bit field.
** packages[0] contains bits 0-31 where 0 is the lowest bit.
** packages[1] contains bits 32-63 where 32 is the lowest bit.
** Similarly for packages[2] and packages[3].
**
** packages is a bit mask where bit 0 set means std pkg, bit 1
** set means pkg A, bit 2 means B, etc. For compatibility, a
** value of zero is synonymous with all ones.
**
** The packages field typically specifies the currently selected
** pkgs unless otherwise noted.
**
**
** Copyright© 1994-1995 Aladdin Systems, inc.
**
*******************************************************************************
** L E G A L N I C E T I E S
*******************************************************************************
This source code is (c) 1995 Aladdin Systems, Inc. You are free to use it
in connection with your own products and distribute it in either source code
or object code form. However, this source code and accompanying written
materials (including instructions for use) are provided "as is" without
warranty of any kind. Further, Aladdin Systems does not warrant, or make
representations regarding the use, or the results of the use, of the source
code or written materials in terms of correctness, accuracy, reliability,
currentness, or otherwise. No oral or written information or advice given
by Aladdin Systems or its employees shall create a warranty, and you may not
rely on such information or advice.
Neither Aladdin Systems nor anyone else who has been involved with the
creation, production, or delivery of the source code shall be liable for
any direct, indirect, consequential, or incidental damages (including damages
for loss of business profits, business interruption, loss of business
information, and the like) arising out of the use or the inability to use the
source code even if Aladdin Systems has been advised of the possibility of
such damages. Because some states do not allow the exclusion or limitation
of liability for consequential or incidental damages or the limitations of
duration of implied warranty, the above limitations may not apply to you.
*******************************************************************************
** A U T H O R I D E N T I T Y
*******************************************************************************
**
** Initials Name
** -------- -----------------------------------------------
** RMT Robert Thorne
**
*******************************************************************************
** R E V I S I O N H I S T O R Y
*******************************************************************************
**
** Date Time Author Description
** -------- ----- ------ ---------------------------------------------
** 08/03/95 RMT Adapted from our test libraries.
**
******************************************************************************/
#include "IMPackages256.h"
// Obligatory string copy utility
static unsigned char *pStrcpy(unsigned char *dest, unsigned char *src) ;
// Implementation
static unsigned char *pStrcpy(unsigned char *dest, unsigned char *src)
{
BlockMoveData(src, dest, (long) *src + 1);
return (dest);
}
Boolean ParsePackageString ( unsigned long *packages, Str255 packageStr )
{
Str255 upperStr ;
Str31 thisPack ;
short index , packSize, len, packNo ;
Boolean good = true ;
unsigned char c ;
(void) pStrcpy ( upperStr, packageStr ) ;
UprString ( upperStr, true ) ; // diacrits are syntax errors, so let them through
// Strategy here is to walk through the string, ignoring space characters. I
// assume that our list is comma delimited. I also assume that the longest possible
// package has 3 letters (for Std).
// I'm also assuming that the package bit string is correctly initialized to a string
// of "1"s
len = upperStr [0] ;
index = 1 ;
packSize = 0 ;
while ( good && index <= len )
{
c = upperStr [index++] ;
switch (c)
{
case ',':
if (packSize > 0 && packSize < 4) // valid size of package
{
thisPack [0] = packSize ;
packNo = GetPackageNumber (thisPack) ;
if ( packNo == -1 )
good = false ; // bail
else
{
SetPackageBit ( packages, packNo, true ) ; // set its bit
packSize = 0 ; // reset for next package
}
}
else
good = false ;
break ;
case ' ': // space character
break ;
default: // Add the charater to the current package
packSize++ ;
thisPack [packSize] = c ;
break ;
}
}
// If we're still good, process any output at the end of the string
if ( good )
{
if ( packSize > 0 && packSize < 4 )
{
thisPack [0] = packSize ;
packNo = GetPackageNumber (thisPack) ;
if ( packNo == -1 )
good = false ; // bail
else
{
SetPackageBit ( packages, packNo, true ) ; // set its bit
packSize = 0 ; // reset for next package
}
}
else
good = false ;
}
return good ;
}